home *** CD-ROM | disk | FTP | other *** search
/ Info-Mac 3 / Info_Mac_1994-01.iso / Development / Source / MultiSession 1.04 Source / Core 27⁄June⁄1993 / CSimpleButton.c < prev    next >
Encoding:
C/C++ Source or Header  |  1993-05-07  |  2.6 KB  |  93 lines  |  [TEXT/KAHL]

  1. /* CSimpleButton.c */
  2.  
  3. #include "CSimpleButton.h"
  4. #include "CWindow.h"
  5. #include "Memory.h"
  6.  
  7. #define OvalRadius (10)
  8.  
  9.  
  10. /* kill things */
  11. /* */            CSimpleButton::~CSimpleButton()
  12.     {
  13.         ERROR(Initialized != True,PRERR(ForceAbort,
  14.             "CSimpleButton::~CSimpleButton called on uninitialized object."));
  15.         ReleaseHandle(Name);
  16.     }
  17.  
  18.  
  19. /* initialize the button */
  20. void            CSimpleButton::ISimpleButton(LongPoint Start, LongPoint Extent,
  21.                         Handle NameString, char Key, short Modifiers, CWindow* TheWindow,
  22.                         CEnclosure* TheEnclosure)
  23.     {
  24.         ERROR(Initialized == True,PRERR(ForceAbort,
  25.             "CSimpleButton::ISimpleButton called on already initialized object."));
  26.         EXECUTE(Initialized = True);
  27.         Name = NameString;
  28.         ERROR(NameString==NIL,PRERR(ForceAbort,"CSimpleButton::ISimpleButton passed NIL for name text."));
  29.         IButton(Start,Extent,Key,Modifiers,TheWindow,TheEnclosure);
  30.     }
  31.  
  32.  
  33. void            CSimpleButton::RedrawNormal(void)
  34.     {
  35.         LongPoint        EffectiveStart;
  36.         LongPoint        EffectiveExtent;
  37.  
  38.         ERROR(Initialized != True,PRERR(ForceAbort,
  39.             "CSimpleButton::RedrawNormal called on uninitialized object."));
  40.         SetUpPort();
  41.         Window->ResetPen();
  42.         Window->SetText(0,0,srcOr,12,0);
  43.         if (!Enabled)
  44.             {
  45.                 Window->SetGreyishTextOr();
  46.             }
  47.         EffectiveStart = ZeroPoint;
  48.         EffectiveExtent = Extent;
  49.         if ((KeyEquivalent == 0x0d) && (KeyModifiers == 0))
  50.             {
  51.                 EffectiveExtent.x -= 2;
  52.                 EffectiveExtent.y -= 2;
  53.                 Window->SetPenSize(3,3);
  54.                 Window->LFrameRoundRect(EffectiveStart,EffectiveExtent,OvalRadius+4,OvalRadius+4);
  55.                 EffectiveStart.x += 4;
  56.                 EffectiveStart.y += 4;
  57.                 EffectiveExtent.x -= 8;
  58.                 EffectiveExtent.y -= 8;
  59.                 Window->SetPenSize(1,1);
  60.             }
  61.         Window->LEraseRoundRect(EffectiveStart,EffectiveExtent,OvalRadius,OvalRadius);
  62.         Window->LFrameRoundRect(EffectiveStart,EffectiveExtent,OvalRadius,OvalRadius);
  63.         HLock(Name);
  64.         Window->LDrawText(EffectiveStart,EffectiveExtent,Name,JustifyCenter);
  65.         HUnlock(Name);
  66.     }
  67.  
  68.  
  69. void            CSimpleButton::RedrawHilited(void)
  70.     {
  71.         LongPoint        EffectiveStart;
  72.         LongPoint        EffectiveExtent;
  73.  
  74.         ERROR(Initialized != True,PRERR(ForceAbort,
  75.             "CSimpleButton::RedrawHilited called on uninitialized object."));
  76.         SetUpPort();
  77.         EffectiveStart = ZeroPoint;
  78.         EffectiveExtent = Extent;
  79.         if ((KeyEquivalent == 0x0d) && (KeyModifiers == 0))
  80.             {
  81.                 EffectiveStart.x += 4;
  82.                 EffectiveStart.y += 4;
  83.                 EffectiveExtent.x -= 10;
  84.                 EffectiveExtent.y -= 10;
  85.             }
  86.         Window->ResetPen();
  87.         Window->SetText(0,0,srcBic,12,0);
  88.         Window->LPaintRoundRect(EffectiveStart,EffectiveExtent,OvalRadius,OvalRadius);
  89.         HLock(Name);
  90.         Window->LDrawText(EffectiveStart,EffectiveExtent,Name,JustifyCenter);
  91.         HUnlock(Name);
  92.     }
  93.